<template>
  <div>
    <BasicForm @register="registerForm">
    </BasicForm>
  </div>
</template>
<script lang="ts" setup>
  import {
    BasicForm,
    useForm,
    FormSchema,
  } from '@/components/Form';

  const props = defineProps(['fieldOptions']);

  const formSchema: FormSchema[] = [
    {
      field: 'fields',
      label: '可访问字段',
      required: true,
      component: 'Select',
      componentProps: {
        mode: 'multiple',
        options: props.fieldOptions,
      },
    },
    {
      field: 'ext_filter',
      label: '额外限制条件',
      component: 'Input',
      required: false,
    },
  ];

  const [registerForm, { validate, setFieldsValue }] = useForm({
    labelWidth: 90,
    baseColProps: { span: 24 },
    schemas: formSchema,
    showActionButtonGroup: false,
  });

  defineExpose({
    validate,
    setFieldsValue,
  })

</script>
